<template>
  <div class="RoleList">
    <!--    面包屑-->
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item :to="{ path: '' }">角色管理</el-breadcrumb-item>
      <el-breadcrumb-item :to="{ path:'' }">角色管理</el-breadcrumb-item>
    </el-breadcrumb>
    <!--    搜索添加部分-->
    <div class="addRoleBtn">
      <el-button type="primary" @click="dialogFormVisible = true">新增角色</el-button>
    </div>
    <!--    搜索-添加角色-->
    <el-dialog title="添加角色" :visible.sync="dialogFormVisible">
      <el-form :model="addRoleform">
        <el-form-item label="角色名称" :label-width="formLabelWidth">
          <el-input v-model="addRoleform.roleName" autocomplete="off"></el-input>
        </el-form-item>
        <!--default-expanded-keys默认展开的菜单，default-checked-keys默认选中的权限-->
        <el-form-item label="角色权限" :label-width="formLabelWidth">
          <el-tree
              :data="powerList"
              show-checkbox
              node-key="id"
              :default-expanded-keys="[1]"
              :default-checked-keys="[2]"
              :props="defaultProps">
          </el-tree>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="dialogFormVisible = false">取 消</el-button>
        <el-button type="primary" @click="dialogFormVisible = false">确 定</el-button>
      </div>
    </el-dialog>
    <!--    表格部分-->
    <template>
      <el-table :data="roleList">
        <el-table-column label="ID">
          <template slot-scope="scope">
            <span>{{ scope.row.id }}</span>
          </template>
        </el-table-column>
        <el-table-column label="角色名称">
          <template slot-scope="scope">
            <span>{{ scope.row.roleName }}</span>
          </template>
        </el-table-column>
        <el-table-column label="角色权限">
          <template slot-scope="scope">
            <span>{{ scope.row.power }}</span>
          </template>
        </el-table-column>
        <el-table-column label="操作">
          <template slot-scope="scope">
            <el-button size="middle" type="text" @click="showRoleMsg(scope.row.hid)">查看</el-button>
            <el-button size="middle" type="text" @click="updateRoleBtn(scope.row.hid,scope.row.address)">编辑</el-button>
          </template>
        </el-table-column>
      </el-table>
    </template>
    <!--    分页-->
    <el-pagination background layout="prev, pager, next" :total="roleCount"
                   @current-change="getPageNumBtn" :current-page="currentPage"
                   :page-size="limitSize"></el-pagination>
  </div>
</template>

<script>
import {mapGetters, mapActions} from 'vuex'

export default {
  name: "RoleList",
  computed: {
    ...mapGetters(['roleList', 'powerList'])
  },
  data() {
    return {
      roleCount: 10,
      limitSize: 2,
      currentPage: 1,
      dialogFormVisible: false,
      addRoleform: {
        roleName: '',
      },
      formLabelWidth: '120px',
      defaultProps: {
        children: 'children',
        label: 'label'
      },
      powerKey: [],
    }
  },
  mounted() {
  },
  methods: {
    showRoleMsg() {

    },
    updateRoleBtn() {

    }
  }
}
</script>

<style scoped>
.addRoleBtn {
  display: flex;
  justify-content: right;
}

</style>
